package com.epam.OOP.cargo;

import java.util.Set;
import java.util.TreeSet;

/**
 * Created with IntelliJ IDEA.
 * User: Yelena_M
 * Date: 05.08.13
 * Time: 12:32
 * To change this template use File | Settings | File Templates.
 */
public class CargoFinder {

    public static Set<Cargo> findByVolume(Set<Cargo> cargos, int volumeFrom, int volumeTo){
        Set<Cargo> listCargo = new TreeSet<Cargo>();
        for(Cargo c : cargos){
            if ((c.getVolume() >= volumeFrom) & (c.getVolume() < volumeTo)) {
                listCargo.add(c);
            }
        }
        return listCargo;
    }

    public static Set<Cargo> findByPrice(Set<Cargo> cargos, int priceFrom, int priceTo){
        Set<Cargo> listCargo = new TreeSet<Cargo>();
        for(Cargo c : cargos){
            if ((c.getPrice() >= priceFrom) & (c.getPrice() < priceTo)) {
                listCargo.add(c);
            }
        }
        return listCargo;
    }
}
